#ifndef ANIMATION_H
#define ANIMATION_H

#include "TinyXML/tinyxml.h"
#include <SFML/Graphics.hpp>
#include <vector>
#include <map>

class Animation{
public:
	std::vector<sf::IntRect> frames, frames_flip;
	float currentFrame, speed;
	bool loop, flip, isPlaying;
	sf::Sprite sprite;
	Animation();
	void tick(float time, bool st);
};

class AnimationManager{
public:
    std::string currentAnim;
	std::map<std::string, Animation> animList;

	AnimationManager();
	~AnimationManager();
	void create(std::string name, sf::Texture &texture, int x, int y, int w, int h, int count, float speed, int step=0, bool Loop=true);
	void loadFromXML(std::string fileName, sf::Texture &t);
	void set(std::string name);
	void draw(sf::RenderWindow &window,int x=0, int y=0);
	void flip(bool b=1);
	void tick(float time, bool st);
	void pause();
	void play();
	void play(std::string name);
	bool isPlaying();
	float getH();
	float getW();
};

#endif